<template>
  <vxe-modal title="选择发布资源" v-model="resourceSelectModal"
             :before-hide-method="beforeHideMethod">
    <template>
      <el-row>
        <el-col>
          <vxe-radio-group v-model="resourceSelect">
            <vxe-radio v-for="item of resourceSelectList" :label="item" :content="item"></vxe-radio>
          </vxe-radio-group>
        </el-col>
        <el-col style="text-align: center;margin-top: 25px;margin-bottom: 5px">
          <el-button size="mini" type="primary" @click="userSelect">确认发布</el-button>
        </el-col>
      </el-row>
    </template>
  </vxe-modal>
</template>

<script>
/**
 * {用户选择资源}
 *
 * @author: 宋康
 * @date: 2023/2/11
 */
export default {
  name: "ResourceSelect",
  props: {
    isShow: {
      type: Boolean,
      required: true
    },
    dataList: {
      type: Array,
      required: true
    }
  },
  data() {
    return {
      resourceSelectModal: false,
      resourceSelect: '',
      resourceSelectList: [],
    }
  },
  methods: {
    beforeHideMethod() {
      this.$emit('update:isShow', false);
    },
    /**
     * {用户选择}
     *
     * @author: 宋康
     * @date: 2023/2/11
     */
    userSelect() {
      if ('' === this.resourceSelect) {
        this.$message.error('无效选择');
      } else {
        this.$emit("user-select", this.resourceSelect);
        this.beforeHideMethod();
      }
    }
  },
  mounted() {
    this.resourceSelectModal = this.isShow;
    this.resourceSelectList = this.dataList;
  },
  watch: {
    isShow(n) {
      this.resourceSelectModal = n;
    },
    dataList(n) {
      this.resourceSelectList = n;
    }
  }
}
</script>

<style scoped>

</style>